﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using Rison.Web.Common;
using Rison.BusinessFacade.Facade.Biz;
namespace Rison.Web.wscp
{
    public partial class WSCPLogon : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnLogin_Click(object sender, ImageClickEventArgs e)
        {

            if (txtPwd.Text.Trim().Length == 0)
                this.Page.ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script>alert('请输入密码！');</script>");
            else
            {
                //DataSourceHelperFacade facade = new DataSourceHelperFacade(InfoCategory.我有诉求);
                CPResultDetailFacade facade = new CPResultDetailFacade();
                //if (txtPwd.Text.Trim().Length != 0 & txtUserId.Text.Trim() != "")
                if (facade.PasswordExistsNew(txtPwd.Text.Trim()))            
                {
                    //if (txtPwd.Text.Trim() == "admin201104028") //&& txtUserId.Text.Trim() == "admin"
                    //2011/03/21 暂时不链接
                    if (System.DateTime.Today <= Convert.ToDateTime(this.Labend.Text) & System.DateTime.Today>= Convert.ToDateTime(this.labbegin.Text))
                    {

                        int departNum = 62;
                        //DataSet ds = facade.GetWSCPbyPwd(txtPwd.Text.Trim());
                        //if (ds.Tables[0].Rows.Count < departNum)
                        //{
                        HttpContext.Current.Session["pwd"] = txtPwd.Text.Trim();
                        Response.Redirect("evaluation.aspx");
                        //}
                        //else
                        //{
                        //    this.Page.ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script>alert('该密码已经完成测评，请重新输入新的密码！');</script>");
                        //}
                    }
                    else
                    {
                        this.Page.ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script>alert('评测时间为" + labbegin.Text+ "至" + Labend.Text + "');</script>");
                    }
                    
                }
                else
                {
                    
                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script>alert('对不起，密码输入错误！');</script>");
                }
            }
            
        }
    }
}
